package com.example.demo;

import ch.qos.logback.core.util.StringUtil;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/Message")
public class message {
    private List<MessageInfo> messageInfos=new ArrayList<>();
    @RequestMapping("/getlist")
    public List<MessageInfo> getlist(){
        return messageInfos;
    }

    @RequestMapping("/getmessage")
    public boolean getmessage(@RequestBody  MessageInfo messageInfo){
        System.out.println(messageInfo.toString());
        if(!StringUtil.isNullOrEmpty(messageInfo.getFrom())&&
                !StringUtil.isNullOrEmpty(messageInfo.getTo())&&
                !StringUtil.isNullOrEmpty(messageInfo.getSay())){
            messageInfos.add(messageInfo);
            return true;
        }
        return false;
    }
}
